package blockchain

import (
	"net/http"

	"private-domain-overseas-service/app/business/api/internal/logic/blockchain"
	"private-domain-overseas-service/app/business/api/internal/svc"
	"private-domain-overseas-service/app/business/api/internal/types"

	"github.com/zeromicro/go-zero/rest/httpx"
	"private-domain-overseas-service/pkg/result"
)

// 区块链钱包转账
func BlockchainWalletTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.BlockchainWalletTransferRequest
		if err := httpx.Parse(r, &req); err != nil {
			result.HttpErrorResult(r, w, err)
			return
		}

		l := blockchain.NewBlockchainWalletTransferLogic(r.Context(), svcCtx)
		err := l.BlockchainWalletTransfer(&req)

		result.HttpResult(r, w, nil, err)
	}
}
